package com.tgm.controller;
import com.tgm.domain.common.PageResult;
import com.tgm.domain.common.Result;
import com.tgm.domain.entity.UserInfo;
import com.tgm.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.bind.DefaultValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户信息表(UserInfo)表控制层
 *
 * @author makejava
 * @since 2025-10-20 20:59:31
 */
@RestController
@RequestMapping("userInfo")
public class UserInfoController{

    @Autowired
    private UserInfoService userInfoService;

    @GetMapping("page")
    public Result page(Integer pageNum, String keyword){
        PageResult<UserInfo> list =  userInfoService.page(pageNum, keyword);
        return Result.success(list);
    }

    @GetMapping("getDep")
    public Result getDep(){
        List<String> list = userInfoService.list().stream().map(UserInfo::getDepartment).distinct().toList();
        return Result.success(list);
    }

    @GetMapping("getGrade")
    public Result getGrade(){
        List<String> list = userInfoService.list().stream().map(UserInfo::getGrade).distinct().toList();
        return Result.success(list);
    }
}

